package com.example.batch.process;

import com.example.batch.dto.IdDto;
import org.springframework.batch.item.ItemProcessor;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @author LiYuhang
 * @version 0.1
 * @application
 * @Date 2021/7/17 21:27
 */
@Component
public class ListItemProcess implements ItemProcessor<List<IdDto>, List<IdDto>> {

    @Override
    public List<IdDto> process(List<IdDto> item) throws Exception {

        String join = item
                .stream()
                .map(IdDto::getId)
                .distinct()
                .collect(Collectors.joining(","));

        System.out.println(item.size());
        System.out.println(join);

        return item;
    }
}
